package com.ztsoft.user.controller.project;

import com.ztsoft.user.pojo.entity.project.Purchaser;
import com.ztsoft.user.service.project.PurchaserService;
import com.ztsoft.user.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@CrossOrigin("*")
@RestController
@RequestMapping("/purchaser")
@Api(tags = "采购人控制层")
public class PurchaserController {

    @Resource
    private PurchaserService purchaserService;

    @PutMapping("/updatePurchaser")
    @ApiOperation(value = "修改采购人", notes = "修改采购人")
    public Result<Object> updatePurchaser(@RequestBody Purchaser purchaser) {
        return purchaserService.updatePurchaser(purchaser);
    }

    @PostMapping("/addPurchaser")
    @ApiOperation(value = "添加采购人", notes = "添加采购人")
    public Result<Object> addPurchaser(@RequestBody Purchaser purchaser) {
        return purchaserService.addPurchaser(purchaser);
    }

    @DeleteMapping("/deletePurchaser/{id}")
    @ApiOperation(value = "删除采购人", notes = "删除采购人")
    public Result<Object> deletePurchaser(@PathVariable("id") String id) {
        return purchaserService.deletePurchaser(id);
    }

    @GetMapping("/getPurchaserMeta")
    @ApiOperation(value = "获取所有采购人主键及名称", notes = "获取所有采购人主键及名称")
    public Result<Object> getPurchaserMeta() {
        return purchaserService.getPurchaserMeta();
    }

}